/*
删除排序链表中的重复元素 II
class Solution {
    public ListNode deleteDuplicates(ListNode head) {
        //虚拟节点
        ListNode newHead = new ListNode(-1); newHead.next = head;
        ListNode pre = newHead;
        ListNode cur = head;
        //空情况
        if(head == null) return null;
        //遍历head
        while(cur != null) {
            //看看当前节点是否与下一个节点相同，如果相同 则一直跳过 并且cur来到最后一个相同的位置
            while(cur.next != null && cur.next.val == cur.val) {
                cur = cur.next;
            }
            //更新pre位置
            //此时无重复节点
            if(pre.next == cur) {
                pre = cur;
            }else {
                //有重复节点 让pre下一个连接到cur下一个 跳过重复节点
                pre.next = cur.next;
            }
            //更新 cur
            cur = cur.next;
        }
        return newHead.next;
    }
}
将二叉搜索树转化为排序的双向链表
class Solution {
    Node pre, head;
    public Node treeToDoublyList(Node root) {
        if(root == null) return null;
        dfs(root);
        head.left = pre;
        pre.right = head;
        return head;
    }
    void dfs(Node cur) {
        if(cur == null) return;
        dfs(cur.left);
        if(pre != null) pre.right = cur;
        else head = cur;
        cur.left = pre;
        pre = cur;
        dfs(cur.right);
    }
}
 */